package com.neusoft.elm;

import java.util.Scanner;

import com.neusoft.elm.po.Admin;
import com.neusoft.elm.po.Business;
import com.neusoft.elm.view.AdminView;
import com.neusoft.elm.view.BusinessView;
import com.neusoft.elm.view.Impl.AdminViewImpl;
import com.neusoft.elm.view.Impl.BusinessViewImpl;

public class ElmAdminEnty {
	
	
	//管理员的操作
	public void work(){
		Scanner sc = new Scanner(System.in);
		
		System.out.println("---------------------------------------------------------");
		System.out.println("|\t\t 鹅了么后台管理系统 \t\t\t|");
		System.out.println("---------------------------------------------------------");
		
		AdminView adminView = new AdminViewImpl();
		BusinessView businessView = new BusinessViewImpl();
		
		Admin admin = adminView.login();
//		冗余测试代码
		if(admin != null){
			System.out.println("登录成功");
			
			int menu = 0;
			
			while(menu!=5){
				
				System.out.println("\n========= 1.所有商家列表=2.搜索商家=3.新建商家=4.删除商家=5.退出系统 =========");
				System.out.println("请输入你选择的菜单");
			
				menu = sc.nextInt();
			
				switch(menu){
				case 1:
//					System.out.println("所有商家列表");
					businessView.listBusinessAll();
					
					break;
				case 2:
//					System.out.println("搜索商家");
					businessView.listBusiness();
					break;
				case 3:
//					TODO 为什么可以用接口调用实现类（Impl类）的方法
//					System.out.println("新建商家");
					businessView.saveBusiness();
					break;
				case 4:
//					System.out.println("删除商家");
					businessView.removeBusiness();
					break;
				case 5:
					System.out.println("退出系统");
					break;
				default:
					System.out.println("没有这个选项！");
				}
			}
		}else{
			System.out.println("管理员姓名或密码错误！");
		}
	}
	
	

	public static void main(String[] args) {
		new ElmAdminEnty().work();
		
	}

}
